home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 533 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: qcd.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Problem with stringcopy
  5. Date: 6 Jan 1996 19:24:17 GMT
  6. Organization: Los Alamos National Laboratory
  7. Distribution: world
  8. Message-ID: <4cmi91$irn@newshost.lanl.gov>
  9. References: <4clguu$9fs@eagle.novo.dk> <yewvimppjz5.fsf@hyll.idt.unit.no> <4cmafq$bm5@clarknet.clark.net>
  10. NNTP-Posting-Host: qcd.lanl.gov
  11.  
  12. In article <4cmafq$bm5@clarknet.clark.net>, eamick@clark.net (Eric Amick)
  13. writes: 
  14. |> Amund Tveit (amundt@pvv.unit.no) wrote:
  15. <snip>
  16. |> >char *Stringcopy(char *source, int startpos, size_t length)
  17. |> >{
  18. |> >    char tmpstring[SIZEBIGENOUGH];
  19. |> >    strncpy((char *)(source+startpos),tmpstring,length);
  20. |> >    return tmpstring;
  21. |> >}
  22. |> 
  23. |> This won't work as written; the first two arguments to strncpy() are 
  24. |> reversed.  The cast is also unnecessary.
  25.  
  26. Those are probably typographical errors. The possibility of declaring
  27. SIZEBIGENOUGH is always an optimistic proposition; but, most importantly, 
  28. this routine contains one of the very common and absolutely disastrous
  29. beginner errors! Anyone?
  30.  
  31. Cheers
  32. Tanmoy
  33. -- 
  34. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  35. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  36. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  37. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  38. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  39. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  40.